package com.neutech.neusys.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.neutech.neusys.service.RegService;
import com.neutech.po.RegistLevel;

@RestController
@RequestMapping("/his/reg")
public class RegController {
	@Autowired
	private RegService regService;
	/**
	 * 添加挂号级别
	 * @param registLevel 挂号级别信息
	 * @return：“success”--成功，“failure”--失败
	 */
	@RequestMapping(value="/toAddRegLevel",method=RequestMethod.POST)
	public String addRegistLevel(@RequestBody RegistLevel registLevel){
		int result = regService.addRegistLevel(registLevel);
		System.out.println(registLevel.getSequenceNo());
		if(result==1){
			return "success";
		}else{
			return "failure";
		}
	}
	/**
	 * 挂号级别页面之前，要先进行查询信息
	 * @return：RegistLevel的对象的集合
	 */
	@RequestMapping("/toQueryReg")
	public List<RegistLevel> queryRegistLevel(){
		return regService.toQueryReg();
	}
	 /** 删除按钮触发的事件：要删除对应的挂号编码、挂号名称、挂号费、挂号限额信息
	 * @param：根据id int
	 */
	@RequestMapping("/toDelReg")
	public String delRegistLevelById(int id) {
		// TODO Auto-generated method stub
		regService.delRegistLevelById(id);
		return "delete completed,pls go and check";
	}
	
}
